var href = window.location.href;
var id = getQueryString('id');
var loginName = getQueryString('loginName');
var endTime = getQueryString('endTime');

var list = '';
var page = 1;
var pageSize = 10;
var keyWord = '';

initList(page,endTime)

function initList(page,keyWord,cb){
	getList(page,keyWord,function(res){
		cb&&cb(res.rows)//更新列表
		// 分页
		$('.M-box11').pagination({
		    totalData:res.total,
		    showData:pageSize,
		    mode: 'fixed',
			count:4,
			pageCount:Math.ceil(res.total/pageSize),
		    callback:function(e){
		       //获取当前页数重新加载数据
				var currentPage = e.getCurrent();
				getList(currentPage,keyWord,function(res){
					$("#tableFromData").bootstrapTable('load', res.rows)
				});
		    }
		});
	});
}

function freezeList(data){
	for(var i in data){
		data[i].type = data[i].type==1?'房卡':'金币';
	}
}

//查看信息
function getList(page,endTime,callback){
   var params = {
	  pageNum:page,
	  pageSize:pageSize,
	  loginName:loginName,
	  infoId:id,
	  type:3,
	  endTime:endTime,
	  beginTime:''
   }
   _POST('/doulai/operLog/list',params).then(function(res){
	  list = res.rows;
	  freezeList(list);
	  InitTable(list);
	  callback&&callback(res)
   })
}

//初始化列表
function InitTable(data){//$dataTableHot.bootstrapTable('refresh);
  $('#tableFromData').bootstrapTable({
        data: data?data:list
  })
}

function getQueryString(name) {
	 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	 var r = window.location.search.substr(1).match(reg);
	 if (r != null) return unescape(r[2]);
	 return null;
}